import { PlayerDialog } from "./PlayerDialog";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { GTextFormat } from "../../../../common/GTextFormat";
import { Language } from "../../../../../extend/language/Language";
import { GBox } from "../../../../../com/mui/containers/GBox";
import { GBoxDirection } from "../../../../../com/mui/containers/globalVariable/GBoxDirection";
import { RewardGoodBox } from "./RewardGoodBox";
import { RewardExpBox } from "./RewardExpBox";
import { EReward } from "../../../../../Message/Public/EReward";
import { ItemConfig } from "../../../resource/ItemConfig";
import { ECareer } from "../../../../../Message/Public/ECareer";
import { Cache } from "../../../cache/Cache";
import { UICompomentPool } from "../../../../../com/mui/utils/UICompomentPool";
import { RewardGoods } from "./RewardGoods";
import { RewardLabel } from "./RewardLabel";
type int = number;
//class RewardList3
    
    export  class RewardList3 extends PlayerDialog
    {
        constructor(arg1: int)
        {
            super();
            this._width = arg1;
            this._line = GlobalClass.getBitmap(ImagesConst.Line3);
            this._line.x = -50;
            this._line.y = 5;
            addChild(this._line);
            this._titleText = new Object /* flash.text.TextField */();
            this._titleText.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._titleText.selectable = false;
            this._titleText.textColor = 16580298;
            this._titleText.filters = [FilterConst.nameGlowFilter];
            this._titleText.defaultTextFormat = new GTextFormat(null, 12, 16383837);
            this._titleText.text = Language.getString(20094);
            this._titleText.y = -3;
            this._titleText.x = (this.width - this._titleText.textWidth) / 2 - 10;
            addChild(this._titleText);
            this._bodySprite = new GBox();
            this._bodySprite.direction = GBoxDirection.VERTICAL;
            this._bodySprite.x = 0;
            this._bodySprite.y = 13;
            addChild(this._bodySprite);
            this._itemSprite = new RewardGoodBox();
            this._itemSprite.direction = GBoxDirection.HORIZONTAL;
            this._expSprite = new RewardExpBox(this.width);
            this._expSprite.direction = GBoxDirection.VERTICAL;
            return;
        }

        public set horGap(arg1: int)
        {
            this._horGap = arg1;
            this._expSprite.horGap = arg1;
            return;
        }

        public showLine(arg1: Boolean, arg2: int=0): void
        {
            this._line.visible = arg1;
            if (arg2 != 0) 
            {
                this._line.width = arg2;
            }
            return;
        }

        public endTaskRes(): void
        {
            this._itemSprite.flyItemTo();
            return;
        }

        public /* override */ updateData(arg1: Array<any>): void
        {
            var loc3=null;
            var loc4=null;
            var loc5=null;
            this.dispose();
            var loc1=0;
            var loc2=arg1.length;
            label281: while (loc1 < loc2) 
            {
                loc3 = arg1[loc1];
                var loc6=loc3.type;
                switch (loc6) 
                {
                    case EReward._ERewardItem:
                    {
                        if (loc3.num == 0) 
                        {
                            ++loc1;
                            continue label281;
                        }
                        if (!((loc5 = ItemConfig.instance.getInfoByCode(loc3.code).item).career == ECareer._ECareerNo) && !(loc5.career & Cache.instance.role.roleInfo.career)) 
                        {
                            ++loc1;
                            continue label281;
                        }
                        (loc4 = UICompomentPool.getUICompoment(RewardGoods)).updateData(loc3);
                        this._itemSprite.addItem(loc4);
                        break;
                    }
                    default:
                    {
                        (loc4 = UICompomentPool.getUICompoment(RewardLabel)).updateData(loc3);
                        this._expSprite.addItem(loc4);
                    }
                }
                ++loc1;
            }
            if (this._expSprite.numChildren > 0) 
            {
                this._expSprite.invalidate();
                this._bodySprite.addChild(this._expSprite);
            }
            if (this._itemSprite.numChildren > 0) 
            {
                this._itemSprite.invalidate();
                this._bodySprite.addChild(this._itemSprite);
            }
            this._bodySprite.invalidate();
            this._itemSprite.y = this._itemSprite.y + 0;
            super.updateData(arg1);
            return;
        }

        public /* override */ updateHeight(arg1: int=1): void
        {
            this._heightStep = arg1;
            if (this._heightStep != 1) 
            {
                if (this._heightStep == 2) 
                {
                    this._line.y = 5;
                    this._titleText.y = 2;
                    this._bodySprite.y = 18;
                }
            }
            else 
            {
                this._line.y = 10;
                this._titleText.y = 2;
                this._bodySprite.y = 23;
            }
            super.updateHeight(arg1);
            return;
        }

        public /* override */ dispose(): void
        {
            var loc1=null;
            var loc2=null;
            this._heightStep = 0;
            this._line.y = 5;
            this._titleText.y = -3;
            this._bodySprite.y = 13;
            while (this._bodySprite.numChildren > 0) 
            {
                loc1 = this._bodySprite.getChildAt(0) as RewardExpBox;
                if (loc1 != null) 
                {
                    (loc1 as RewardExpBox).dispose();
                    continue;
                }
                loc1 = this._bodySprite.getChildAt(0) as RewardGoodBox;
                (loc1 as RewardGoodBox).disposeChild();
                this._bodySprite.removeChild(loc1);
            }
            return;
        }

        public /* override */ get width(): number
        {
            return this._width;
        }

        public /* override */ get height(): number
        {
            var loc1=0;
            var loc3=null;
            var loc2=this._bodySprite.numChildren;
            var loc4=this._bodySprite.y - 2;
            while (loc1 < loc2) 
            {
                loc3 = this._bodySprite.getChildAt(loc1) as RewardExpBox;
                if (loc3 == null) 
                {
                    loc3 = this._bodySprite.getChildAt(loc1) as RewardGoodBox;
                    if (loc3 != null) 
                    {
                        loc4 = loc4 + loc3.height;
                    }
                }
                else 
                {
                    loc4 = loc4 + loc3.height;
                }
                ++loc1;
            }
            return loc4;
        }

        /* internal */ /* var */_line: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_titleText: Object /* flash.text.TextField */;

        /* internal */ /* var */_bodySprite: GBox;

        /* internal */ /* var */_itemSprite: RewardGoodBox;

        /* internal */ /* var */_expSprite: RewardExpBox;

        /* internal */ /* var */_width: int;

        /* internal */ /* var */_horGap: int;

        /* internal */ /* var */_heightStep: int;
    }
